package com.syl.service.impl;

import com.syl.dao.UserDao;
import com.syl.dao.impl.UserDaoImpl;
import com.syl.entity.User;
import com.syl.service.UserService;

import java.util.List;

/**
 * --- 就那样---
 *
 * @author SYL
 * @date 2025/8/1
 * @desc
 */
public class UserServiceImpl implements UserService {

    UserDao userDao =new UserDaoImpl();



    @Override
    public User login(String username, String password) {
        System.out.println("业务层处理");
        User user= null;
        try {
            user = userDao.login(username,password);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


        return user;
    }

    @Override
    public User check(String username) {
        System.out.println("业务层处理查看用户名是否存在");
        User user= null;
        try {
            user = userDao.checkUser(username);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }


        return user;
    }

    @Override
    public boolean register(User user) {

        boolean isok = userDao.register(user);




        return isok;
    }

    @Override
    public List<User> getAllUser() {
        List<User> allUser = userDao.getAllUser();

        return allUser;
    }

    @Override
    public boolean delectUser(int id) {
        //删除成功 true
         boolean isok = userDao.delectUser(id);



        return isok;
    }
}
